package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetOrderProductDetailInfoBean;
import com.ymatou.query.trading.api.service.GetOrderProductDetailInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.constant.ECode;

/**
 * 根据商品Id获取订单中商品详情 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetOrderProductDetailInfo {

	private static GetOrderProductDetailInfoBean getorderproductdetailinfobean;
	private static GetOrderProductDetailInfoCall getorderproductdetailinfocall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据商品Id获取订单中商品详情");
	}

	@Before
	public void caseUp() {

		getorderproductdetailinfobean = new GetOrderProductDetailInfoBean();
		getorderproductdetailinfocall = new GetOrderProductDetailInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getorderproductdetailinfocall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderProductDetailInfo_001() {
		Logger.start(true,"根据商品Id获取订单中商品详情成功");
		try {
			// 创建订单
			Map map = new OrderCallService().appSaveOrder();
			String productid = (String) map.get("ProductId");
			String CatalogId = (String) map.get("CatalogId");
			// int UserId = (Integer) map.get("UserId");
			int OrderId = (Integer) map.get("OrderId");
			Logger.comment("OrderId:" + OrderId);
			// 参数
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(1);
			getorderproductdetailinfobean.setOrderStatusList(list);
			// String productid="7aa433ed-bf8a-4e7e-aee5-1f0d4eba45cb";
			getorderproductdetailinfobean.setProductId(productid);
			// 发送请求
			getorderproductdetailinfocall.setData(getorderproductdetailinfobean);
			getorderproductdetailinfocall.callService();
			Logger.comment("getorderproductdetailinfocall send:" + getorderproductdetailinfocall.getEntityString());
			Logger.comment("getorderproductdetailinfocall response:" + getorderproductdetailinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getorderproductdetailinfocall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getorderproductdetailinfocall.getMsg(), "验证Msg");
			Logger.verifyEquals(1, getorderproductdetailinfocall.getOrderCatalogInfoList().size(), "验证查询结果数量");
			Logger.verifyEquals(CatalogId, getorderproductdetailinfocall.getOrderCatalogInfoList().get(0)
					.getCatalogId(), "验证CatalogId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}